function getStyle(obj,attr){
   var value;
   if(obj.currentStyle){
   value= obj.currentStyle[attr];
   }else{
   value= window.getComputedStyle(obj,null)[attr];
   }
  //返回一个不带单位的属性值
   if(attr=="opacity"){
     return Math.round(parseFloat(value)*100);
   }else{
     return parseInt(value);
   }
}

function move(obj,json,num,fn){
    if(obj.timer){
	    clearInterval(obj.timer);
	}
	
	obj.timer= setInterval(function(){
	//获取属性值，不带单位
		var bstop=true;//同步属性是否达到目标值；
		for(var attr in json){
			var target=json[attr];
			var current= (getStyle(obj,attr));
				if(!num){
					num = 10;
				}
			var speed = (target-current)/num;
				speed>0 ? speed= Math.ceil(speed): speed=Math.floor(speed);
				// var speed =1;
				//比较属性值	 
				if(current != target){
					bstop=false;
					if(attr=="opacity"){
					obj.style[attr] = (current+speed)/100;
					}else{
					obj.style[attr] = current+speed+"px";
					}
				}
				
		}
		if(bstop){
			clearInterval(obj.timer);
			if(fn){
				fn();
			}
		}
	},40);
}